<template>
    <div>
        <el-form :inline="true" :model="formInline" class="demo-form-inline">
        <el-form-item label="标题">
            <el-input clearable v-model="formInline.title" placeholder="请输入关键字"></el-input>
        </el-form-item>
        <el-form-item label="作者">
            <el-input clearable v-model="formInline.author" placeholder="请输入关键字"></el-input>
        </el-form-item>
        <el-form-item label="发稿人">
            <el-input clearable v-model="formInline.postedBy" placeholder="请输入关键字"></el-input>
        </el-form-item>
        <el-form-item label="机构" v-if="isjg">
            <el-select v-model="formInline.organization" placeholder="请选择">
                <el-option
                v-for="item in options"
                :key="item.id"
                :label="item.name"
                :value="item.id">
                </el-option>
            </el-select>
        </el-form-item>
        <el-form-item label="日期范围">
            <el-date-picker
                clearable
                v-model="formInline.date"
                value-format="yyyy-MM-dd HH:mm:ss"
                format="yyyy-MM-dd HH:mm:ss"
                type="daterange"
                range-separator="至"
                start-placeholder="开始日期"
                end-placeholder="结束日期">
                </el-date-picker>
        </el-form-item>
        <el-form-item>
            <el-button type="primary" @click="onSubmit">查询</el-button>
        </el-form-item>
        </el-form>
    </div>
</template>
<script>
import { organizationApiqueryAll, organizationApiadd, organizationApiedit, organizationApidelete } from "@/api/organizationApir";
export default{
    name:'search',
    props:{
        isjg:{
            type:Boolean,
            default:false
        }
    },
    data(){
        return{
            formInline: {
                date:[],
                title: '',
                author: '',
                postedBy:'',
                // organization:'',
                beginTime:'',
                endTime:'',
            },
            options:[],
            params: {
        name: '',
        parentId: '',
      },
        }
    },
    created(){
        this.getlist()
    },
    methods: {
    getlist() {
      organizationApiqueryAll(this.params).then((res) => {
        if (res.code == 0) {
          this.options = res.data
        }
      });
    },
      onSubmit() {
        if(this.formInline.date&&JSON.stringify(this.formInline.date) != '[]'){
            this.formInline.beginTime = this.formInline.date[0]
            this.formInline.endTime = this.formInline.date[1]
        }else{
            this.formInline.beginTime = ""
            this.formInline.endTime = ""
        }
        this.$emit("searchclick",this.formInline)
      }
    }
} 
</script>